package org.papervision3d.core.animation.track
{
	import org.papervision3d.core.animation.keyframe.AbstractKeyFrame;
	import org.papervision3d.core.log.PaperLogger;
	import org.papervision3d.core.math.Quaternion;
	import org.papervision3d.objects.DisplayObject3D;

	public class TranslationTrack extends AbstractTrack
	{
		public function TranslationTrack(target:DisplayObject3D)
		{
			super(target);
		}
		
		public override function addKeyFrame(keyframe:AbstractKeyFrame):void
		{
			if(!keyframe || !keyframe.data || keyframe.data.length != 3)
			{
				PaperLogger.error("TranslationTrack#addKeyFrame : keyframe data should contain 3 values (x, y, z)! " + keyframe.data);
				return;
			}
			super.addKeyFrame(keyframe);
		}
		
		public override function tick(seconds:Number):void
		{
			super.tick(seconds);
			
			if(current && next)
			{
				matrix.n14 = current.data[0] + alpha * (next.data[0] - current.data[0]);
				matrix.n24 = current.data[1] + alpha * (next.data[1] - current.data[1]);
				matrix.n34 = current.data[2] + alpha * (next.data[2] - current.data[2]);
			}
			else if(current)
			{
				matrix.n14 = current.data[0];
				matrix.n24 = current.data[1];
				matrix.n34 = current.data[2];
			}
		}
	}
}